<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of manipulasi
 *
 * @author Obi
 */
class M_tarif_kirim extends DataMapper {

    var $table = 'tarif_kirim';
    var $key = 'id';

    function __construct() {
        parent::__construct();
    }

    //put your code here
    function insert($form) {
        $this->db->insert($this->table, $form);
    }

    function update($form, $id) {
        $this->db->where($this->key, $id);
        $this->db->update($this->table, $form);
    }

    function delete($id) {
        $this->db->where($this->key, $id);
        $this->db->delete($this->table);
    }

    function biaya_pengiriman() {
        $sql = "
            select 
                tarif_kirim.*,
                kota.nama_kota,
                provinsi.nama_provinsi
            from 
                tarif_kirim,
                kota,
                provinsi,
                mitra_pengiriman
            where
                tarif_kirim.id_mitra=mitra_pengiriman.id and
                tarif_kirim.id_kota=kota.id and
                kota.id_provinsi=provinsi.id";
        $query = $this->db->query($sql);
        return $query->result();
    }

    function cari_spesifik($id=NULL) {
        $sql = "
            select 
                tarif_kirim.*,
                kota.nama_kota,
                provinsi.nama_provinsi,
                mitra_pengiriman.nama_mitra
            from 
                tarif_kirim,
                kota,
                provinsi,
                mitra_pengiriman
            where
                tarif_kirim.id_mitra=mitra_pengiriman.id and
                tarif_kirim.id_kota=kota.id and
                kota.id_provinsi=provinsi.id and
                tarif_kirim.id='$id'";
        $query = $this->db->query($sql);
        return $query->row();
    }

}

?>
